package com.ruyuan.event.streaming.schema;

import com.ruyuan.event.streaming.pojo.EventClientLog;
import com.ruyuan.event.streaming.pojo.EventJoinLog;
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.serialization.SerializationSchema;
import org.apache.flink.api.common.typeinfo.TypeHint;
import org.apache.flink.api.common.typeinfo.TypeInformation;

import java.io.IOException;

public class EventJoinLogSchema implements DeserializationSchema<EventJoinLog>, SerializationSchema<EventJoinLog> {
    @Override
    public EventJoinLog deserialize(byte[] message) throws IOException {
        return EventJoinLog.parseFrom(message);
    }

    @Override
    public boolean isEndOfStream(EventJoinLog nextElement) {
        return false;
    }

    @Override
    public byte[] serialize(EventJoinLog element) {
        return element.toByteArray();
    }

    @Override
    public TypeInformation<EventJoinLog> getProducedType() {
        return TypeInformation.of(new TypeHint<EventJoinLog>() {});
    }
}
